﻿Imports System.Data
Imports System.Data.OleDb
Imports geraLaudosAutomatico.conexao
Imports System.Text

Public Class fabricanteDAO
    Private sql As New StringBuilder
    Private objConn As New conexao
    Private i As Integer
    Private fabricante As New fabricanteVO

    'Public Function getFabricantes() As Generic.List(Of fabricanteVO)
    '    sql.Clear()
    '    sql.Append("SELECT *FROM FABRICANTE ORDER BY DESC_FABRICANTE")
    '    Dim oReader As OleDbDataReader
    '    Dim lista As New Generic.List(Of fabricanteVO)
    '    Try
    '        Dim oComando As New OleDbCommand(sql.ToString, objConn.abreConexao(True))
    '        oReader = oComando.ExecuteReader
    '        While oReader.Read
    '            fabricante = New fabricanteVO
    '            fabricante.ID_FABRICANTE = IIf(IsDBNull(oReader("ID_FABRICANTE")), Nothing, oReader("ID_FABRICANTE"))
    '            fabricante.DESC_FABRICANTE = IIf(IsDBNull(oReader("DESC_FABRICANTE")), Nothing, oReader("DESC_FABRICANTE"))
    '            lista.Add(fabricante)
    '        End While
    '        Return lista
    '    Catch ex As Exception
    '        Throw ex
    '    Finally
    '        objConn.fechaConexao()
    '    End Try
    'End Function

    Public Function getFabricantes() As DataTable
        sql.Clear()
        sql.Append("SELECT *FROM FABRICANTES ORDER BY DESC_FABRICANTE ")
        
        Dim DS As New DataSet
        Try
            Dim comando As New OleDbCommand(sql.ToString, objConn.abreConexao(True))
            Dim adaptador As New OleDbDataAdapter(comando)
            adaptador.Fill(DS, "FABRICANTE")
        Catch ex As Exception
            Throw ex
        End Try
        Return DS.Tables("FABRICANTE")
    End Function
End Class
